package com.kimwu.design.mediator.monarch;

import com.kimwu.design.mediator.official.Official;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 君主抽象类
 */
public abstract class Monarch {

    /**
     * 君主保持着和各个官员的联系
     */
    protected ConcurrentHashMap<String, Official> officials = new ConcurrentHashMap<>();

    /**
     * 录用官员
     * @param name
     * @param official
     */
    public void addOfficial(String name,Official official){
        this.officials.put(name,official);
    }

    /**
     * 将官员革职查办
     * @param name
     */
    public void removeOfficial(String name){
        this.officials.remove(name);
    }

    /**
     * 处理各个官员之间的互相参奏的折子
     * @param name
     * @param method
     */
    public abstract void execute(String name,String method);
}